.\" Hey Emacs! This file is -*- nroff -*- source.
.\"
.\" Author: Eamon Walsh (ewalsh@tycho.nsa.gov) 2007
.TH "selabel_media" "5" "29 Nov 2011" "Security Enhanced Linux" "SELinux API documentation"
.SH "NAME"
selabel_media \- userspace SELinux labeling interface and configuration file format for the media contexts backend
.
.SH "SYNOPSIS"
.B #include <selinux/label.h>
.sp
.BI "int selabel_lookup(struct selabel_handle *" hnd ,
.in +\w'int selabel_lookup('u
.BI "char **" context ,
.br
.BI "const char *" device_name ", int " unused ");"
.in
.sp
.BI "int selabel_lookup_raw(struct selabel_handle *" hnd ,
.in +\w'int selabel_lookup('u
.BI "char **" context ,
.br
.BI "const char *" device_name ", int " unused ");"
.
.SH "DESCRIPTION"
The media contexts backend maps from media device names such as "cdrom" or "floppy" into security contexts. It is used to find the appropriate context for establishing context mounts on these devices. The returned \fIcontext\fR must be freed using \fBfreecon\fR(3).
.br
\fBselabel_lookup\fR(3) describes the function with its return and error codes.
.sp
The integer lookup argument is currently unused and should be set to zero.
.sp
Any messages generated by \fBselabel_lookup\fR(3) are sent to \fIstderr\fR
by default, although this can be changed by \fBselinux_set_callback\fR(3).
.sp
.BR selabel_lookup_raw (3)
behaves identically to \fBselabel_lookup\fR(3) but does not perform context
translation.
.sp
The \fBFILES\fR section details the configuration files used to determine the media context.
.
.SH "OPTIONS"
In addition to the global options described in \fBselabel_open\fR(3), this backend recognizes the following options:
.TP
.B SELABEL_OPT_PATH
A non-null value for this option specifies a path to a file that will be opened in lieu of the standard \fImedia\fR contexts file.
.
.SH "FILES"
The media context file used to retrieve a default context depends on the \fBSELABEL_OPT_PATH\fR parameter passed to \fBselabel_open\FR(3). If \fINULL\fR, then the \fBSELABEL_OPT_PATH\fR value will default to the active policy media contexts location (as returned by \fBselinux_media_context_path\fR(3)), otherwise the actual \fBSELABEL_OPT_PATH\fR value specified is used.
.sp
The default media contexts file is:
.RS
.I /etc/selinux/{SELINUXTYPE}/contexts/files/media
.RE
.sp
Where \fI{SELINUXTYPE}\fR is the entry from the selinux configuration file \fIconfig\fR (see \fBselinux_config\fR(5)).
.
.SH "FILE FORMAT"
Each line within the \fImedia\fR file is as follows:
.RS
.I device_name context
.RE
.sp
Where:
.RS
.I device_name
.RS
The media identifier (e.g. cdrom, floppy, disk and usb).
.RE
.I context
.RS
The context to be used for labeling the device.
.RE
.RE
.sp
Example:
.RS
# contexts/files/media
.br
cdrom system_u:object_r:removable_device_t
.br
floppy system_u:object_r:removable_device_t
.br
disk system_u:object_r:fixed_disk_device_t
.
.SH "NOTES"
If contexts are to be validated, then the global option \fBSELABEL_OPT_VALIDATE\fR must be set before calling \fBselabel_open\fR(3). If
this is not set, then it is possible for an invalid context to be returned.
.
.SH "SEE ALSO"
.ad l
.nh
.BR selinux "(8), " selabel_open "(3), " selabel_lookup "(3), " selabel_stats "(3), " selabel_close "(3), " selinux_set_callback "(3), " selinux_media_context_path "(3), " freecon "(3), " selinux_config "(5) "
